/*class searchPage
 *
 *page instance of searchPage
 *with a searchBox
 *
 *
 *since version: 0.5
 *
 */
//instance
var searchPage = null;
function SearchPage()
{
    this.innerHTML = this.defaultHTML;
    this.body = new DOMObject("body");
    this.searchInput = new DOMObject("searchInput");
    this.searchSummit = new DOMObject("searchSummit");
    this.dropHint = new DOMObject("dropHint");
}
SearchPage.prototype.defaultHTML = "loading...";
SearchPage.prototype.load = function()
{
    var This = this;
    var xhr = new XMLHttpRequest();
    xhr.open("GET",'searchPage.ajax',true)
    xhr.onreadystatechange = function()
    {
	if(xhr.readyState ==4)
	{
	    This.innerHTML = xhr.responseText;
	    //add 404 handler at next version
	}
    }
    xhr.send(null);
}
SearchPage.prototype.show = function()
{
    this.body.$().innerHTML = this.innerHTML;
    //if not loaded or not complete loaded
    if(this.innerHTML == this.defaultHTML)
    {
	this.load();
	setTimeout(function(){searchPage.show()},1000);
	return false;
    }
    this.initInteraction();
}
SearchPage.prototype.initInteraction = function()
{
    this.searchInput.$().onchange = bookLib.showSearchHint;
    this.searchSummit.$().onclick = bookLib.searchViaSearchBox;
}
SearchPage.prototype.applySearch = function()
{
    searcher.applySearch(this.searchInput.$().value);
    return true;
}